package com.siwei.mes.controller;

import com.siwei.mes.entity.OrderClock;
import com.siwei.mes.service.OrderClockService;
import org.springframework.web.bind.annotation.*;
import com.siwei.mes.common.query.PageQuery;
import com.siwei.mes.common.result.ApiResult;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.common.validator.AddGroup;
import com.siwei.mes.common.validator.PageGroup;
import com.siwei.mes.common.validator.UpdateGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.validation.annotation.Validated;

import static com.siwei.mes.common.exception.handler.MessageHandler.assertTrue;

import javax.annotation.Resource;

/**
 * 工单打卡(OrderClock)表控制层
 *
 * @author makejava
 * @since 2023-12-05 09:31:33
 */
@Api(value = "工单打卡")
@RestController
@RequestMapping("orderClock")
public class OrderClockController {
    @Resource
    private OrderClockService orderClockService;

    @ApiOperation(value = "新增工单打卡")
    @PostMapping("/create")
    public Json create(@RequestBody @Validated(AddGroup.class) OrderClock entity) {
        return Json.succ().data(ApiResult.addColumn("id", orderClockService.create(entity)));
    }

    @ApiOperation(value = "根据主键id获取工单打卡")
    @GetMapping("loadById")
    public Json loadById(@RequestParam("id") Long id) {
        return Json.succ().data(orderClockService.loadById(id));
    }

    @ApiOperation(value = "获取所有工单打卡")
    @PostMapping("getAll")
    public Json getAll(@RequestBody OrderClock entity) {
        return Json.succ().data(ApiResult.addList(orderClockService.getAll(entity)));
    }

}
